﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DreametryMIS
{
    public partial class frmVerifier : Form
    {
        int userId;
        String user, real, connectionString;
        Process p = new Process();
        public frmVerifier()
           
        {
            InitializeComponent();
         

           
        }
        private void frmVerifier_Load(object sender, EventArgs e)
        {
            labeldbname.Text = ClassFlow.global_fullname;
            VerifyierFileWatch.EnableRaisingEvents = true;
            ClassFlow.global_count = "SELECT Count(*) FROM EmploeeTask WHERE flow_id = '2' OR flow_id = '5'";
            ClassFlow.unique_SQL_String = "SELECT * FROM EmploeeTask WHERE flow_id = '2' OR flow_id = '5'";
            this.flowControl1.getAll();
           
            taskInProgress.Path = @"\\server-pc\Dropbox\_____Codiga\_____AI and PSD Files\____TASKS IN PROGRESS\" + ClassFlow.global_nickname +@"\logs\comment";
        }

        private void fileSystemWatch_Created(object sender, FileSystemEventArgs e)
        {
            String path = e.FullPath;

            String result = System.IO.Path.GetFileName(path);
            String y = Path.GetDirectoryName(result.TrimEnd(Path.DirectorySeparatorChar));
           

            notifyicon.ShowBalloonTip(5000, "", "New Folder For Verification Added"+ " " + result +
                 "                                  " +
                            "                               ", ToolTipIcon.Info);
     
            listboxlog.Items.Add(DateTime.Now + " >>New folder Added >>-->" + result);
            this.listboxlog.SelectedIndex = this.listboxlog.Items.Count - 1;
            
        }

        private void showToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Show();
        }

        private void listboxlog_Click(object sender, EventArgs e)
        {
            String path = fileSystemWatch.Path;
            Process p = new Process();
            string str = @"" + path;
            p.StartInfo.FileName = str;
            p.Start();
        }

        private void fileSystemWatch_Changed(object sender, FileSystemEventArgs e)
        {

        }    

        private void fileSystemWatch_Renamed(object sender, RenamedEventArgs e)
        {
            
            String path = e.FullPath;

            String result = System.IO.Path.GetFileName(path);
            String y = Path.GetDirectoryName(result.TrimEnd(Path.DirectorySeparatorChar));
            
            notifyicon.ShowBalloonTip(5000, "", "Folder Renamed" + " " + result , ToolTipIcon.Info);
            listboxlog.Items.Add(DateTime.Now + " >>>>Folder Renamed >>-->" + result);
            this.listboxlog.SelectedIndex = this.listboxlog.Items.Count - 1;
        }

        private void listboxlog_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void fileSystemWatch_Deleted(object sender, FileSystemEventArgs e)
        {
            String path = e.FullPath;
            String result = System.IO.Path.GetFileName(path);
            String y = Path.GetDirectoryName(result.TrimEnd(Path.DirectorySeparatorChar));
           
            notifyicon.ShowBalloonTip(10000, "", "Folder Deleted" + "                                  " +
                "                                  " + result , ToolTipIcon.Info);
            listboxlog.Items.Add(DateTime.Now + " >>>>>>>>Deleted Folder >>-->" + result);
            this.listboxlog.SelectedIndex = this.listboxlog.Items.Count - 1;

            //  txtpath.Text = 
            //listboxlog.Items.Add(dirName);
            // Path.GetLast




        }
        private void btnverifySuperMug_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://docs.google.com/spreadsheets/d/1WHaVOKANZolyfh1-7aOVQfkt89S0SPdkw9RJgB1STaM/edit#gid=299208238");
        }
        private void btnverifySuperMugAU_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://docs.google.com/spreadsheets/d/1C_yxEdMQnveDc4O8zyAQ4_I0JLiuKs0qkLoMYa9wrI4/edit#gid=299208238");
        }

        private void btnverifySpruchDruck_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://docs.google.com/spreadsheets/d/1TkBCH6nlMWuoNwiV5dxCXxNl54x8ZKSX2lIkvOgm2RE/edit#gid=299208238");
        }

        private void btnverifyMugEmpire_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://docs.google.com/spreadsheets/d/1ziajb6ofJXFkIo8HLX8dKU987401iO5xVm_SOKaW900/edit#gid=299208238");
        }

       

        private void paneltools_MouseLeave(object sender, EventArgs e)
        {
           // paneltools.Visible = false;
        }

        private void labeltools_MouseHover(object sender, EventArgs e)
        {
            //paneltools.Visible = true;
        }
        
        private void btnlogger_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://docs.google.com/forms/d/1h_-OBm9LRawnBZl9-hpgrlpIWgSE5jsTlB4sVMK3KtY/viewform?c=0&w=1");
        }

        private void btnSuperMugWB_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://mugsuk.myshopify.com/admin/auth/login");
        }

        private void btnSuperMugAUWB_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://supermug-com-au.myshopify.com/admin/auth/login");
        }

        private void btnSpruchDruckWB_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://spruck-druck.myshopify.com/admin/auth/login");
        }

        private void btnMugEmpireWB_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://mug-empire.myshopify.com/admin/auth/login");
        }

        private void btnTipsyMeWB_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://tipsyme.myshopify.com/admin/auth/login");
        }

        private void btnCushionCrushWB_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://cushioncrush.myshopify.com/admin/auth/login");
        }

        private void btnHMWB_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://hubbyandwifey.myshopify.com/admin/auth/login");
        }

        private void btnBTWB_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://beer-time.myshopify.com/admin/auth/login");
       

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnHome_Click(object sender, EventArgs e)
        {
        
            foreach (var item in listboxlog.Items)
            {
                writeFile.Main(item.ToString(), @"\\SERVER-PC\Dropbox\_____Codiga\___For Verification\save.txt");
            }


              //MessageBox.Show("Programs saved!");
               this.Close();
               MainForm mf = new MainForm();
               mf.Show();
           // this.Close();


        }

        private void paneltools_MouseHover(object sender, EventArgs e)
        {
           // paneltools.Visible = true;
        }

        private void labeltools_MouseLeave(object sender, EventArgs e)
        {
            //paneltools.Visible = true;
        }

        private void btnAdobePS_Click(object sender, EventArgs e)
        {
            string str = @"C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe";
            p.StartInfo.FileName = str;
            p.Start();
        }

        private void VerifyierFileWatch_Changed(object sender, FileSystemEventArgs e)
        {
            notifyicon.ShowBalloonTip(5000, "", "New files/ design For Verification", ToolTipIcon.Info);
            this.flowControl1.getAll();

        }

        private void taskInProgress_Created(object sender, FileSystemEventArgs e)
        {
            String path = e.FullPath;
            String result = System.IO.Path.GetFileName(path);
            String y = Path.GetDirectoryName(result.TrimEnd(Path.DirectorySeparatorChar));
            String x = Path.GetFileNameWithoutExtension(result);

          if (File.Exists(path))
          {
             File.Delete(path);
          }

            // MessageBox.Show(x);

            notifyicon.ShowBalloonTip(10000, "Comment on you Task", x, ToolTipIcon.Info);
        }

        private void taskInProgress_Deleted(object sender, FileSystemEventArgs e)
        {
            String path = e.FullPath;
            String result = System.IO.Path.GetFileName(path);
            String y = Path.GetDirectoryName(result.TrimEnd(Path.DirectorySeparatorChar));
            String x = Path.GetFileNameWithoutExtension(result);

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

            // MessageBox.Show(x);

            notifyicon.ShowBalloonTip(20000, "Comment on you Task", x, ToolTipIcon.Info);
        }

        private void labelvw_Click(object sender, EventArgs e)
        {
            if (panelVerification.Visible == false)
            {

                panelVerification.Visible = true;

            }
            else
            {
                panelVerification.Visible = false;
            }
            panelErrorlog.Visible = false;
            panelwebsite.Visible = false;
            paneltools.Visible = false;
        }

        private void labelerrorlog_Click(object sender, EventArgs e)
        {
            
            if (panelErrorlog.Visible == false)
            {

                panelErrorlog.Visible = true;

            }
            else
            {
                panelErrorlog.Visible = false;
            }
            panelVerification.Visible = false;
            panelwebsite.Visible = false;
            paneltools.Visible = false;
        }

        private void labelwebsite_Click(object sender, EventArgs e)
        {
            if (panelwebsite.Visible == false)
            {

                panelwebsite.Visible = true;

            }
            else
            {
                panelwebsite.Visible = false;
            }
            panelErrorlog.Visible = false;
            panelVerification.Visible = false;
            paneltools.Visible = false;
        }

        private void labelerrorlog_MouseHover(object sender, EventArgs e)
        {
            
        }

        private void btnAppT_Click(object sender, EventArgs e)
        {
            if (paneltools.Visible == false)
            {

                paneltools.Visible = true;

            }
            else
            {
                paneltools.Visible = false;
            }
            panelwebsite.Visible = false;
            panelErrorlog.Visible = false;
            panelVerification.Visible = false;
        }

        private void picAdobeAI_Click(object sender, EventArgs e)
        {
            string str = @"C:\Program Files\Adobe\Adobe Illustrator CC 2015\Support Files\Contents\Windows\Illustrator.exe";
            p.StartInfo.FileName = str;
            p.Start();
        }

        private void frmVerifier_Move(object sender, EventArgs e)
        {
           /* if (this.WindowState == FormWindowState.Normal)
            {

                var fileList = new DirectoryInfo(@"D:\").GetFiles("*.*", SearchOption.TopDirectoryOnly);

                foreach (var fileInfo in fileList)
                {

                    notifyicon.ShowBalloonTip(5000, "", fileInfo.ToString(), ToolTipIcon.Info);

                }
            }*/
           
        }
        /*private void GetDirectoryName() {
            String path = "C:/folder1/folder2/file.txt";
            String lastFolderName = Path.GetFileName(Path.GetDirectoryName(path));
            MessageBox.Show(lastFolderName);
        }*/
     
    }
}
